<%@page import="com.iflysse.bbs.model.UserInfo"%>
<%@page import="com.iflysse.bbs.dao.impl.UserDaoImpl"%>
<%@page import="com.iflysse.bbs.dao.UserDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="base.jsp"%>
<%
	String account = request.getParameter("account") == null ? null
			: request.getParameter("account").toString();
	String password = request.getParameter("password") == null ? null
			: request.getParameter("password").toString();
	String returnUrl = request.getParameter("returnUrl") == null ? null
			: request.getParameter("returnUrl").toString();
	
	if(account == null || password == null){
		response.sendRedirect("login.jsp");
		return;
	}
	
	UserDao userDao = new UserDaoImpl();
	UserInfo user = userDao.getUser(account, password);
	
	if(user != null){
		session.setAttribute("currentUser", user);
		String script = "<script>parent.window.location.href='" + baseUrl + returnUrl + "'</script>";
		out.print(script);
	}else{
		request.setAttribute("msg", "账号或密码出错...");
		request.getRequestDispatcher("/pages/login.jsp").forward(request, response);
	}
%>